﻿using ConsoleApp1.Model;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    internal class MyHostedService : IHostedService
    {
        public ILogger<MyHostedService> Logger { get; set; }

        public BookToXmlTool bookToXmlTool1 { get; set; }
        public MyHostedService(ILogger<MyHostedService> logger, BookToXmlTool bookToXmlTool)
        {
            this.Logger = logger;
            this.bookToXmlTool1 = bookToXmlTool;
        }

        /// <summary>
        /// 应用程序运行的时候，调用
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            TestMode testMode = new TestMode()
            {
                title = "xxx",
                bookFilte = new BookFilte() { testOne = "www", txtValue = "wwww", testTwo = "xxx" },
                testOne = "xxx",
                bookFiltes = new List<BookFilte>() { new BookFilte { testOne = "www", txtValue = "wwww", testTwo = "xxx" }, new BookFilte { testOne = "www", txtValue = "wwww", testTwo = "xxx" } },
                testTwo = "wwww"
            };
            bookToXmlTool1.Start(testMode);
            //bookToXmlTool1.Run(typeof(TestMode), testMode);
        }

        /// <summary>
        /// 应用程序停止的时候，调用
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task StopAsync(CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }
    }
}
